package com.dys.testwrap;

/**
 * @className: com.dys.testwrap.Girl
 * @description: 封装: 提高代码的安全性,高内聚,低耦合
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/07/17 下午9:33
 */
public class Girl {
    private int age;

    public int readAge() {
        return this.age;
    }

    public void setAge(int age) {
        if (age < 0 || age > 200) {
            throw new RuntimeException("年龄不合法");
        } else if (age > 30) {
            this.age = 18;
        } else {
            this.age = age;
        }
    }
}
